//window.location.search      location可以看成地址栏   search表示查询字符串     ?fid=1&fname=apple
let queryString = window.location.search.substring(1)
if(queryString) { // fid=1
    var fid = queryString.split("=")[1]
    window.onload = function () {
        loadFruit(fid)
    }


    loadFruit = function (fid) {
        axios({
            method:'get',
            url:'edit',
            params: {
                fid: fid,
            }

        }
    ).then(response=> {
            let fruit = response.data;
            $("#fid").value = fruit.fid;
            $("#fname").value = fruit.fname;
            $("#price").value = fruit.price;
            $("#fcount").value = fruit.fcount;
            $("#remark").value = fruit.remark;
        });
    };
    update=function () {
     let fid = $("#fid").value
     let fname =     $("#fname").value
     let price = $("#price").value
     let fcount = $("#fcount").value
     let remark= $("#remark").value
        axios({
            method: "post",
            url: 'update',
            data:{
                fid: fid,
                fname: fname,
                price: price,
                fcount: fcount,
                remark: remark,

            }
        }).then(response=> {
           let flag= response.data.flag
            let msg = response.data.msg;
                if (flag) {
                    window.location.href = "index.html";
                }
                console.log(flag);
                console.log(msg);

        }
        )
    }
}